<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AirdropModal Example</title>
    <style>
        body {
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background-color: #f8f9fa;
            transition: background-color 0.3s;
        }
        
        .container {
            text-align: center;
            padding: 2rem;
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            max-width: 500px;
            width: 100%;
            transition: background-color 0.3s, box-shadow 0.3s;
        }
        
        h1 {
            color: #333;
            margin-bottom: 1.5rem;
            transition: color 0.3s;
        }
        
        p {
            color: #666;
            margin-bottom: 2rem;
            line-height: 1.6;
            transition: color 0.3s;
        }
        
        .buttons {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 12px;
            margin-bottom: 2rem;
        }
        
        button {
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            background-color: #4285f4;
            color: white;
            font-size: 14px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        
        button:hover {
            background-color: #3367d6;
        }
        
        .secondary {
            background-color: #f1f3f4;
            color: #202124;
        }
        
        .secondary:hover {
            background-color: #e8eaed;
        }
        
        /* Theme switcher styles */
        #theme-switcher-controls {
            position: fixed;
            top: 20px;
            left: 20px;
            z-index: 100;
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            padding: 12px;
            background-color: rgba(255, 255, 255, 0.8);
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            max-width: 300px;
        }
        
        body.dark-mode #theme-switcher-controls {
            background-color: rgba(0, 0, 0, 0.8);
        }
        
        .theme-btn {
            padding: 8px 12px;
            font-size: 12px;
            font-weight: 500;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            color: white;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
        }
        
        .theme-btn:hover {
            opacity: 0.9;
        }
        
        .theme-btn.default { background-color: #2563EB; }
        .theme-btn.cyberpunk { background-color: #6D28D9; }
        .theme-btn.forest { background-color: #059669; }
        .theme-btn.sunset { background-color: #F97316; }
        .theme-btn.oceanic { background-color: #0E7490; }
        .theme-btn.minty { background-color: #10B981; }
        .theme-btn.royalpurple { background-color: #7E22CE; }
        .theme-btn.crimsongold { background-color: #DC143C; }
        .theme-btn.deepsea { background-color: #1E90FF; }
        .theme-btn.toggle-dark { background-color: #4B5563; }
        
        /* 暗色模式样式 */
        body.dark-mode {
            background-color: #202124;
        }
        
        body.dark-mode .container {
            background-color: #303134;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
        }
        
        body.dark-mode h1 {
            color: #e8eaed;
        }
        
        body.dark-mode p {
            color: #9aa0a6;
        }
        
        body.dark-mode .secondary {
            background-color: #3c4043;
            color: #e8eaed;
        }
        
        body.dark-mode .secondary:hover {
            background-color: #4a4e51;
        }
        
        /* Custom scrollbar */
        ::-webkit-scrollbar { width: 6px; height: 6px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: #9ca3af; border-radius: 3px; }
        body.dark-mode ::-webkit-scrollbar-thumb { background: #4b5563; }
    </style>
</head>
<body>
    <!-- Theme Switcher Controls -->
    <div id="theme-switcher-controls">
        <button data-theme="theme-web3" class="theme-btn default">Default</button>
        <button data-theme="theme-cyberpunk" class="theme-btn cyberpunk">Cyberpunk</button>
        <button data-theme="theme-forest" class="theme-btn forest">Forest</button>
        <button data-theme="theme-sunset" class="theme-btn sunset">Sunset</button>
        <button data-theme="theme-oceanic" class="theme-btn oceanic">Oceanic</button>
        <button data-theme="theme-minty" class="theme-btn minty">Minty</button>
        <button data-theme="theme-royalpurple" class="theme-btn royalpurple">RoyalPurple</button>
        <button data-theme="theme-crimsongold" class="theme-btn crimsongold">CrimsonGold</button>
        <button data-theme="theme-deepsea" class="theme-btn deepsea">DeepSea</button>
        <button id="toggle-dark-mode" class="theme-btn toggle-dark">Toggle Dark</button>
    </div>
    
    <div class="container">
        <h1>AirdropModal Demo</h1>
        
        
        <div class="buttons">
            <button id="showModalBtn">Show Modal</button>
            
        </div>
    </div>
    <script src="dist/airdrop-modal.umd.js"></script>
    <script>
    // Initialize after page loads
    document.addEventListener('DOMContentLoaded', function() {
        // Use AirdropModal.default as constructor
        const AirdropModalClass = AirdropModal.default;
        let modal;

        // Initialize modal
        function initModal() {
            modal = new AirdropModalClass({
                appName: 'Airdrop Checker',
                appLogo: 'https://placehold.co/48x48/2563EB/FFFFFF?text=AC',
                logos: {
                    web3: 'https://placehold.co/48x48/2563EB/FFFFFF?text=AC',
                    cyberpunk: 'https://placehold.co/48x48/00F0FF/0C0C1A?text=CY',
                    forest: 'https://placehold.co/48x48/228B22/F5FFF5?text=FP',
                    sunset: 'https://placehold.co/48x48/FF7F50/FFFFFF?text=SP',
                    oceanic: 'https://placehold.co/48x48/00CED1/FFFFFF?text=OP',
                    minty: 'https://placehold.co/48x48/66CDAA/FFFFFF?text=MP',
                    royalpurple: 'https://placehold.co/48x48/6A0DAD/FFFFFF?text=RP',
                    crimsongold: 'https://placehold.co/48x48/DC143C/FFFFFF?text=CG',
                    deepsea: 'https://placehold.co/48x48/1E90FF/FFFFFF?text=DS'
                },
                projectDesc: 'This demo project is airdropping 1,000,000 $DEMO tokens to lucky users.',
                coinSymbol: '$TOKEN',
                endDate: new Date(Date.now() + 20 * 24 * 60 * 60 * 1000).toISOString(), // 20 days later
                darkMode: document.body.classList.contains('dark-mode'),
                accentTheme: 'web3',
                enableDragOnMobile: true,
                onCheck: async function(address) {
                    // Simulate async query
                    console.log('Checking address:', address);
                    return new Promise(resolve => {
                        setTimeout(() => {
                            // Randomly return success or failure
                            const isEligible = Math.random() > 0.5;
                            if (isEligible) {
                                const amount = (Math.random() * 1000 + 50).toFixed(2);
                                const usdValue = (amount * (Math.random() * 0.5 + 0.1)).toFixed(2);
                                resolve({
                                    isEligible: true,
                                    amount: amount,
                                    usdValue: usdValue
                                });
                            } else {
                                resolve({
                                    isEligible: false
                                });
                            }
                        }, 2000);
                    });
                },
                onClaim: async function(amount) {
                    // Simulate claim operation
                    console.log('Claiming airdrop amount:', amount);
                    return new Promise(resolve => {
                        setTimeout(() => {
                            resolve(true);
                        }, 1500);
                    });
                },
                onConnectWallet: async function() {
                    // Simulate wallet connection
                    console.log('Connecting wallet');
                    return new Promise(resolve => {
                        setTimeout(() => {
                            // Generate random address
                            const randomAddr = '0x' + Array(40).fill(0).map(() => 
                                Math.floor(Math.random() * 16).toString(16)).join('');
                            resolve(randomAddr);
                        }, 1500);
                    });
                },
                onClose: function() {
                    console.log('Modal closed');
                }
            });
        }

        // Initialize modal
        initModal();
        
        // Show modal button
        document.getElementById('showModalBtn').addEventListener('click', function() {
            // Reset modal state to initial query state
            modal.reset();
            modal.show();
        });
        
        // Use AirdropModal.default.ModalStatus to get status enum
        const ModalStatus = AirdropModalClass.ModalStatus;
        
        
       
        
        
        
        // Theme switcher
        const themeSwitcher = document.getElementById('theme-switcher-controls');
        if (themeSwitcher) {
            themeSwitcher.addEventListener('click', function(event) {
                const button = event.target.closest('button');
                if (!button) return;
                
                if (button.id === 'toggle-dark-mode') {
                    // Toggle dark mode
                    document.body.classList.toggle('dark-mode');
                    
                    // Update modal's dark mode setting
                    if (modal) {
                        modal.toggleTheme(document.body.classList.contains('dark-mode') ? 'dark' : 'light');
                    }
                } else {
                    // Switch theme
                    let theme = button.getAttribute('data-theme');
                    if (theme && modal) {
                        // 从theme-web3格式转换为web3格式
                        theme = theme.replace(/^theme-/, '');
                        console.log(`Applying theme: ${theme}`);
                        modal.setTheme(theme);
                    }
                }
            });
        }
    });
    </script>
</body>
</html>